/*
 * Course.java
 *
 * Created on October 27, 2007, 10:59 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package MainClasses;

import MainClasses.Event.Event;
import java.util.*;
/**
 * @author andrewcutler
 */
public class Course {
    
    private int courseID;
    private int period;
    private String courseName;
    private String periodName;
    private String teacher;
    private String courseURL;
    private boolean[] daysToMeet;
    private ArrayList<Event> assignments;
    
    public Course()
    {
        daysToMeet = new boolean[7];
        daysToMeet[0] = false;
        daysToMeet[6] = false;
        assignments = new ArrayList<Event>();
    }
    /**
     * @override
     * @return
     */
    
    @Override
    public String toString()
    {
        return period + ") " + courseName + " : " + teacher;
    }
    public void setCourseName(String s)
    {
        courseName = s;
    }
    public void setId(int id)
    {
        courseID = id;
    }
    
    public void setPeriod(int p)
    {
        period = p;
        setPeriodName();
    }
    
    private void setPeriodName()
    {
        if(period == 0)
        {
            periodName = "Advisor Period";
        }
        else if(period == 500)
        {
            periodName = "";
        }
        else
        {
            periodName = "Period " + period;
        }
    }
    
    public void setTeacher(String s)
    {
        teacher = s;
    }
    
    public void setCourseURL(String s)
    {
        courseURL = s;
    }
    
    public void meets(boolean m, boolean t, boolean w, boolean th, boolean f)
    {
        daysToMeet[1] = m;
        daysToMeet[2] = t;
        daysToMeet[3] = w;
        daysToMeet[4] = th;
        daysToMeet[5] = f;
    }
    
    public void addEvent(Event a)
    {
        if(this.equals(main.getUserCourse()))
        {
            assignments.add(a);
        }
        else{
        boolean add = true;
        for(Event e : assignments)
        {
            if(e.equal(a.getUniqueID()))
                add = false;
        }
        if(add)
            assignments.add(a);
        }
    }
    
    public void removeEvent(Event e)
    {
        assignments.remove(e);
    }
    
    public Event getEvent(int i)
    {
        return assignments.get(i);
    }
    
    public ArrayList<Event> getEvents()
    {
        return assignments;
    }
    
    public String getTeacher()
    {
        return teacher;
    }
    
    public String getPeriodName()
    {
        return periodName;
    }
    
    public String getCourseURL()
    {
        return courseURL;
        
    }
    
    public int getPeriod()
    {
        return period;
    }
    
    public int getCourseID()
    {
        return courseID;
    }
    
    public String getCourseName()
    {
        return courseName;
    }
    
    public boolean equals(Object o)
    {
        if(o instanceof Course)
        {
            if(((Course)o).getCourseID() == this.courseID)
                return true;
        }
        return false;
    }
    
    
    
    
}
